insert into asm_gecera_anag_utenti_v2
                 
                
select distinct
               (select max(numeroindividuale) from asm_anagrafe_terni)+rownum ,
               
               '',case when a.sog_cogn is null then sog_ragsoc else sog_cogn end,
                a.sog_nome, 
                case when a.sog_codfis is null then a.sog_pariva else sog_codfis end,'',
                    a.eletopo_des, a.ind_num , a.ind_suf,a.sog_id,
                    
                 (select max(numero_fami) from asm_anagrafe_terni)+rownum numero_famiglia,
                    'DOM',sog_dtnas,
                   a.sog_flsesso sesso,
                    1,1
                    --,c.con_anno,c.con_id
               from v_soggetto      a ,
               (select distinct sog_id--,con_anno,con_id 
               from contratto where az_id='01'
             and ver_dtfine=to_date('31129999','ddmmyyyy')
             and tcon_id = 10) c
   
              where  
            
             (select sog_codfis from asm_gecera_anag_utenti_v2  v where  a.sog_codfis=v.sog_codfis and dom='DOM') is  null
           and a.az_id='01'
              and a.sog_id=c.sog_id
          
              